package com.lancoo.ccas53.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lancoo.ccas53.entity.*;
import com.lancoo.ccas53.pojo.common.PageInfo;
import com.lancoo.ccas53.pojo.dto.*;
import com.lancoo.ccas53.pojo.vo.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 学生 服务类
 * </p>
 *
 * @author quin.song
 * @since 2024-05-20
 */
public interface StudentService extends IService<Student> {

    /**
     * 同步学生
     *
     * @param taskId
     * @param schoolId
     */
    void syncStudent(Integer taskId, String schoolId);

    /**
     * 获取班级
     *
     * @param taskId
     * @param baseCollegeId
     * @param majorId
     * @param gradeId
     * @return
     */
    List<ClassVo> getClassByTaskId(Integer taskId, String baseCollegeId, String majorId, String gradeId);

    /**
     * 条件获取全部学生
     *
     * @param taskId
     * @param page
     * @param baseCollegeId
     * @param majorId
     * @param gradeId
     * @param classId
     * @param keyWord
     * @param selectionScopePre
     * @return
     */
    PageInfo<Student> getStudentByConditions(Integer taskId, IPage page, String baseCollegeId, String majorId, String gradeId, String classId, String keyWord, Integer selectionScope, Integer selectionScopePre);


    /**
     * 根据基础平台学生Id获取学生信息
     *
     * @param baseStudentId
     * @return
     */
    Student getStudentInfoByBaseStudentId(String baseStudentId, Integer taskId);

    /**
     * 获取选课任务
     *
     * @param
     * @param param
     * @return
     */
    List<CssTaskDto> getCssTask(CssTaskInput param);

    /**
     * 获取选课课程列表
     *
     * @param taskId
     * @param param
     * @return
     */
    StuCourseDto getStudentCourseView(Integer taskId, StuCourseInput param);

    /**
     * 获取预选课课程列表
     *
     * @param taskId
     * @param roundId
     * @return
     */
    List<Course> getPreCourseList(Integer taskId, Long roundId, Long studentId);

    /**
     * 学生选课
     *
     * @param taskId
     * @param param
     * @return
     */
    Integer selectCourse(Integer taskId, SelectCourseInput param);

    /**
     * 学生退选课程
     *
     * @param taskId
     * @param param
     * @return
     */
    Integer cancelCourse(Integer taskId, SelectCourseInput param);

    /**
     * 学生选课
     * @param taskId
     * @param studentId
     * @param teachingClassId
     * @return
     */
//    int selectCourse1(Integer taskId, Long studentId, Long teachingClassId,Long cancelTeachingClassId);

    /**
     * 学生选课 lua脚本实现
     *
     * @param addSelectCourse
     * @return
     */
    int selectCourseOptimize(AddSelectCourse addSelectCourse);

    /**
     * 学生选课-预选课 lua脚本实现
     *
     * @param addSelectCoursePre
     * @return
     */
    int selectCoursePre(AddSelectCoursePre addSelectCoursePre);

    /**
     * 退选
     * @param taskId
     * @param studentId
     * @param teachingClassId
     * @param flag  2退选   3管理员移除
     * @return
     */
//    int cancelCourse1(Integer taskId, Long studentId, Long teachingClassId,Integer flag);

    /**
     * 学生退选 lua脚本实现
     *
     * @param addCancelCourse
     * @return
     */
    int cancelCourseOptimize(AddCancelCourse addCancelCourse);

    /**
     * 学生选择预选课
     *
     * @param taskId
     * @param courseId
     * @param flag
     * @return
     */
    String selectPreCourse(Integer taskId, Long courseId, Integer flag, Long studentId);

    /**
     * 判断是否已选择该课程
     *
     * @param taskId
     * @param courseId
     * @param studentId
     * @param studyNature
     * @param teachingClassType
     * @return
     */
    TeachingClass isExistSelectCourse(Integer taskId, String courseId, String studentId, String studyNature, String teachingClassType);

    /**
     * 判断学生是否是禁选学生
     *
     * @param studentId
     * @return
     */
    List<CssProhibitStudent> isProhibitStudent(Long studentId);

    /**
     * 获取学生选课数据
     *
     * @param getAvailableCondition
     * @return
     */
    StudentTeachingClassView getAvailableTeachingClass(GetAvailableCondition getAvailableCondition);

    /**
     * @param taskId
     * @return
     */
    Object saveRedisData(Integer taskId, List<TeachingClass> teachingClasses, String tempKey);

    /**
     * 根据学生id获取已选课程
     *
     * @param studentId
     * @param teachingClassType
     * @return
     */
    List<StudentTeachingClass> getSelectedByStudentId(Integer taskId, Long studentId, Integer teachingClassType);

    /**
     * 获取学生选课要求
     *
     * @param taskId
     * @param studentId
     * @param studyNature
     * @return
     */
    SelectionRequireVo getSelectionRequire(Integer taskId, Long studentId, Integer studyNature);

    /**
     * 根据教学班id获取学生列表
     *
     * @param page
     * @param teachingClassId
     * @return
     */
    PageInfo<Student> getStudentsByTeachingClassId(IPage page, Long teachingClassId, String baseCollegeId, String gradeId, String classId, String keyword, Integer taskId);

    List<Student> getAllStudent(Integer taskId, String keyword);

    List<Student> getClassStudent(Integer taskId, String keyword);

    IPage<AllScheduleVo> getAllStudentPage(Page<AllScheduleVo> page, Integer taskId, String gradeId, String classId, String keyword, String collegeId);

    void exportStudent(HttpServletResponse response, Integer taskId, Integer flag, MultipartFile file);

    void importTeachingClass(HttpServletResponse response, Integer taskId, Integer flag, MultipartFile file);

    void exportTeachingClass(HttpServletResponse response);

    void updateTeachingClassWeek();

    Boolean teacherSelectToStu(Integer taskId, TeachingClassStudent param);

    Boolean teacherCancelToStu(Integer taskId, TeachingClassStudent param);
}
